/*
 * main.cpp
 *
 *  Created on: Jun 3, 2010
 *      Author: sdaniele
 */


#include "common.h"
#include "systemc.h"

using namespace noti;

static bool st_report_producers;
namespace noti{
	void test(int sim_time, bool is_thread);

	bool is_report_producers(){
		return st_report_producers;
	}
}

#define usage\
		"\nusage: %s SIM_TIME IS_THREAD REPORT_PRODUCERS\n\nwhere:    SIM_TIME int - simulation time,in ms       IS_THREAD {t|m} - use threads or methods\n,      REPORT_PRODUCERS {0|1} - report producer type jobs\n"

void inline usage_and_exit(char** argv)
{
	printf(usage, argv[0]);
	exit(1);
}

inline bool parse_is_thread(char** argv, unsigned int idx){
	if(std::string(argv[idx])==std::string("t"))
		return true;
	else if(std::string(argv[idx])!=std::string("m"))
		usage_and_exit(argv);
	return false;
}

int sc_main(int argc, char** argv){
	if(argc!=4)
		usage_and_exit(argv);

	int sim_time = atoi(argv[1]);				//simulation time
	bool is_thread = parse_is_thread(argv,2);	//use threads instead of methods
	st_report_producers = atoi(argv[3]);		//also producers report their execution

	test(sim_time, is_thread);

	::std::cout << sc_time_stamp() << ::std::endl;
	return 0;
}
